package com.youme.tools.cg.db.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public final class ConnHelper {
  ConnHelper() {}

  private static String DRIVER = PropertiesReader.getInstance().getProperty("driver.name");
  private static String URL = PropertiesReader.getInstance().getProperty("url");
  private static String UID = PropertiesReader.getInstance().getProperty("username");
  private static String PWD = PropertiesReader.getInstance().getProperty("password");

  /**
   * 获得JDBC数据库连接
   * 
   * @return Connection
   */
  public static Connection getJDBCConn() {
    Connection conn = null;
    try {
      Class.forName(DRIVER);
      conn = DriverManager.getConnection(URL, UID, PWD);
    } catch (ClassNotFoundException e) {
      System.out.println(String.format("获得数据库连接失败：%s", e.getMessage()));
    } catch (SQLException e) {
      System.out.println(String.format("获得数据库连接失败：%s", e.getMessage()));
    }
    return conn;
  }

}
